package com.ewentsai;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

public class Article {

    private int id;
    private int pid;
    private int rootId;
    private String title;
    private String content;;
    private Date CreateTime;
    private boolean isLeaf;
    private int grade;
    private String author;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getPid() {
        return pid;
    }

    public void setPid(int pid) {
        this.pid = pid;
    }

    public int getRootId() {
        return rootId;
    }

    public void setRootId(int rootId) {
        this.rootId = rootId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Date getCreateTime() {
        return CreateTime;
    }

    public void setCreateTime(Date createTime) {
        CreateTime = createTime;
    }

    public boolean isLeaf() {
        return isLeaf;
    }

    public void setLeaf(boolean leaf) {
        isLeaf = leaf;
    }

    public int getGrade() {
        return grade;
    }

    public void setGrade(int grade) {
        this.grade = grade;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public void getInitFormRS(ResultSet rSet){
        try {
            int id = rSet.getInt("id");
            int pid = rSet.getInt("pid");
            int rootId = rSet.getInt("rootid");
            String title = rSet.getString("title");
            String content= rSet.getString("content");
            Date CreateTime = rSet.getDate("time");
            int isLeaf = rSet.getInt("isLeaf");
            int grade = rSet.getInt("grade");
            String author= rSet.getString("author");

            setId(id);
            setPid(pid);
            setRootId(rootId);
            setTitle(title);
            setContent(content);
            setCreateTime(CreateTime);
            if(isLeaf==1){
                setLeaf(true);
            }else if(isLeaf==0){
                setLeaf(false);
            }
            setGrade(grade);
            setAuthor(author);

        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}